home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacHack 1995
/
MacHack 1995.toast
/
Presentations
/
Presentations ’90
/
A⁄Rose Techniques
/
FunMacros.h
next >
Wrap
Text File
|
1990-06-08
|
2KB
|
61 lines
/*
* FunMacros.h - Fun macros to use in A/ROSE development.
*
* Mark D. Rustad. 6/8/90.
*/
/* Functions */
/*
* The following three macros allow the mSData, mOData and mDataPtr to
* be accessed as if they were other types. For instance:
*
* xxx(AROSEmessage *mp)
* {
* struct abc
* {
* short s1;
* char c1[2];
* };
*
* printf("3rd byte of mOData is %02X\n", ODataAs(unsigned char, mp)[2]);
* printf("c1[1] in mSData is %02X\n", SDataAs(struct abc, mp)->c1[1]);
* }
*/
#define ODataAs(x,y) ((x *)((y)->mOData))
#define SDataAs(x,y) ((x *)((y)->mSData))
#define DPAs(x,y) ((x *)((y)->mDataPtr))
/*
* The following macro will swap the mFrom and mTo addresses, set to low-order
* bit of mCode (to indicate a reply), set mStatus to the indicated value and
* send the message. This could actually all be done as an MPW 3.0 C in-line
* function. Anyone game to try it?
*/
#define Reply(x,y) {tid_type t;\
t = (x)->mFrom, (x)->mFrom = (x)->mTo, (x)->mTo = t;\
(x)->mCode |= 1;\
(x)->mStatus = y;\
Send(x);\
}
/*
* The following macro will calculate the offset (in bytes) to the field
* given in the second argument within the structure given in the first
* argument. This evaluates to a constant at compile time. For example:
* GetOffset(AROSEmessage, mFrom)
* evaluates to 14. Among other things, this allows symbolic references to
* fields in structures in MPW in-line expansions.
*/
#define GetOffset(x,y) (&((x *)0)->y)
/* End of FunMacros.h */